<?php
/*
 * To change this template, choose Tools | Templates and open the template in the editor.
 */
?>
<h1>Edit Info</h1>

<div class="form">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'edit-form',
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true
        ),
        'htmlOptions' => array(
            'enctype' => 'multipart/form-data'
        )
    ));
    ?>

    <p class="note">
        Fields with <span class="required">*</span> are required.
    </p>

    <div class="row">
        <?php echo $form->labelEx($model, 'username'); ?>
        <?php echo $form->textField($model, 'username', array('disabled' => true)); ?>
        <?php echo $form->error($model, 'username'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'email'); ?>
        <?php echo $form->textField($model, 'email', array('disabled' => true)); ?>
        <?php echo $form->error($model, 'email'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'fullname'); ?>
        <?php echo $form->textField($model, 'fullname'); ?>
        <?php echo $form->error($model, 'fullname'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'gender'); ?>
        <?php echo $form->radioButtonList($model, 'gender', array('0' => 'Nữ', '1' => 'Nam'), array('separator' => ' ', 'labelOptions' => array('style' => 'display:inline'),)); ?>
        <?php echo $form->error($model, 'gender'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'avatar'); ?>
        <?php
        if ($model->avatar != null) {
            echo '<img width="80px" src="' . Yii::app()->baseUrl . '/upload/user/' . $model->id . '/avatar/' . $model->avatar . '"><br>';
        }
        ?>
        <?php echo $form->fileField($model, 'avatar'); ?>
        <?php echo $form->error($model, 'avatar'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton('Cập nhật'); ?>
        <?php
        if ($model->password != null) {
            echo '<a href="' . Yii::app()->createUrl('user/changepassword') . '">Đổi mật khẩu</a><br>';
        } else {
            echo '<a href="' . Yii::app()->createUrl('user/createpassword') . '">Đặt mật khẩu mới</a><br>';
        }
        ?>
    </div>

    <?php $this->endWidget(); ?>
</div>
<!-- form -->

